home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fatted Calf
/
The Fatted Calf.iso
/
Applications
/
Games
/
Solitaire
/
Sources
/
Spider
/
SpiderGameDelegate.m
< prev
next >
Wrap
Text File
|
1994-01-23
|
2KB
|
94 lines
/* indent:4 tabsize:8 font:fixed-width */
#import "SpiderGameDelegate.h"
#import "SpiderSuitDelegate.h"
#import "../Solitaire/Solitaire.h"
#import "Spider.h"
@implementation SpiderGameDelegate
- clickedCard:aCard in:aCardPileView
{
id cardPile = [aCardPileView cardPile];
if ((aCard == [cardPile cardAt:CS_TOP]) && (![aCard isFaceUp]))
{
[aCard flip];
[aCardPileView display];
}
return self;
}
- (BOOL)draggedPile:aCardPile from:aCardPileView
{
id cardPile = [aCardPileView cardPile];
id firstCard = [aCardPile cardAt:CS_TOP];
int cardIndex = [cardPile cardIndex:firstCard];
int i;
int total;
id newCard;
CardSuit suit;
CardValue lastValue;
if ([firstCard isFaceUp])
{
total = [cardPile cardCount];
lastValue = [firstCard value];
suit = [firstCard suit];
/* Can only drag if all cards above are same suit and in
descending sequence */
for (i = cardIndex + 1; i < total; i++)
{
newCard = [cardPile cardAt:i];
if ([newCard suit] != suit) return NO;
if ([newCard value] != --lastValue) return NO;
}
/* Move cards above dragged card onto temporary pile */
while (++cardIndex < [cardPile cardCount])
{
[aCardPile addCard:[cardPile cardAt:cardIndex]];
}
return YES;
}
return NO;
}
- (BOOL)canAcceptPile:aCardPile from:sender in:aCardPileView
{
id droppingCard = [aCardPile cardAt:CS_BOTTOM];
id targetCard = [[aCardPileView cardPile] cardAt:CS_TOP];
if (targetCard)
{
if (([targetCard isFaceUp]) &&
([targetCard value] == [droppingCard value] + 1))
{
return YES;
}
}
else
{
return YES;
}
return NO;
}
- getOffset:(float *) xOffset :(float *) yOffset forSize:(CardSize)aSize
{
*xOffset = 0.0;
if (aSize == CS_SMALL)
*yOffset = 20.0;
else
*yOffset = 25.0;
return self;
}
@end